package com.wolfking.demo.leetcode;

import java.util.Arrays;

public class YanhuiTriangle {
    public static void main(String[] args) {
        final int[][] triangle = triangle(10);
        for (int[] array : triangle) {
            System.out.println(Arrays.toString(array));
        }
    }

    private static int[][] triangle(int n) {
        int[][] proof = new int[n][];
        for (int i = 0; i < n; i++) {
            proof[i] = new int[i + 1];
            proof[i][0] = 1;
            proof[i][proof[i].length - 1] = 1;
            for (int j = 1; j < proof[i].length - 1; j++) {
                proof[i][j] = proof[i - 1][j] + proof[i - 1][j - 1];
            }
        }
        return proof;
    }
}
